package com.leyou.item.mapper;

import com.leyou.common.mapper.LyBaseMapper;
import com.leyou.item.dto.BrandDTO;
import com.leyou.item.entity.Brand;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author LT
 * @version 1.0.0
 * @ClassName BrandMapper.java
 * @Description TODO 品牌映射器
 * @createTime 2020年05月04日 12:43:00
 */
public interface BrandMapper extends LyBaseMapper<Brand> {

    /**
     * 插入中间表数据
     * @param id
     * @param cids
     * @return 返回插入的条数
     */
    int insertBrandAndCategory(@Param("bid") Long id, @Param("cids") List<Long> cids);

    /**
     * 通过Cid查找品牌
     * @param cid
     * @return
     */
    @Select("SELECT b.* FROM tb_brand b, tb_category_brand cb " +
            "WHERE b.id = cb.brand_id AND cb.category_id = #{cid}")
    List<BrandDTO> findBrandByCid(Long cid);
}
